<template>
  <div>
    <a-card class="contentFullHeight"  :bodyStyle="{padding : '10px 10px'}">
      <div class="">
        <a-card :bordered="true" class="searchBox" :bodyStyle="{padding : '10px 24px'}">
          <a-form layout="inline">

            <a-form-item label="操作账号">
              <a-select v-model="searchParams.sb" allowClear >
                <a-select-option value="0">全部</a-select-option>
                <a-select-option value="1">admin</a-select-option>
                <a-select-option value="2">by11</a-select-option>
                <a-select-option value="3">by11che11</a-select-option>
              </a-select>
            </a-form-item>

            <a-form-item label="操作类型">
              <a-select v-model="searchParams.sb" allowClear>
                <a-select-option value="0">全部</a-select-option>
                <a-select-option value="1">新增</a-select-option>
                <a-select-option value="2">修改</a-select-option>
                <a-select-option value="3">删除</a-select-option>
              </a-select>
            </a-form-item>

            <a-form-item label="操作时间">
              <a-range-picker />
            </a-form-item>


            <a-form-item>
              <a-button type="primary" icon="search" @click="handleSearch">查询</a-button>
            </a-form-item>

          </a-form>
        </a-card>
      </div>


      <a-table :columns="columns" :dataSource="data"

               bordered size="small" rowKey="id"
               :pagination="pagination" :loading="loading"
               @change="handleTableChange"
      >

      </a-table>



    </a-card>


  </div>
</template>

<script>

  import {
    getOperationLogList
  } from "@/api/system/log"

  export default {
    components: {},
    data() {
      return {

        /*   -------搜索框--------*/
        searchParams: {
          code: '',
          sb: '0',
          gz:'0',
          xh:'0'
        },

        /*   -------分页--------*/
        pagination: this.$defaultSettings.pagination ,

        /*   -------表格--------*/
        loading: false,
        columns:[
          {
            title: '操作类型',
            dataIndex: 'type',
            // fixed: 'left'
          },
          {
            title: '操作内容',
            dataIndex: 'operationValue'
          },
          {
            title: '操作员',
            dataIndex: 'createBy'
          },
          {
            title: '操作模块',
            dataIndex: 'operationModel'
          },
          {
            title: '操作时间',
            dataIndex: 'createTime'
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   width: 100,
          //   scopedSlots: {customRender: 'action'},
          //   fixed: 'right'
          // }
        ],
        data:[]

      }
    },
    inject: ['upShow'],filters: {},
    created() {

    },
    mounted() {
      this.getTableData()
    },
    methods: {


      handleTableChange(pagination, filters, sorter) {
        this.pagination = pagination
        let sortOrder = ''
        let sortField = sorter.field ? sorter.field : ''
        if (sorter.order) {
          sortOrder = sortOrder === 'ascend' ? 'asc' : 'desc'
        }
        this.getTableData(sortField, sortOrder)
      },

      getTableData(sortField, sortOrder) {


        this.loading = true

        const parameter = {
          _search: true,//是否分页查询
          pageSize: this.pagination.pageSize || 10,
          pageNumber: this.pagination.current || 1,
          sortField: sortField || '',
          sortOrder: sortOrder || '',
          // data:this.searchParams
          data: {
            keywords: this.searchParams.name
          }
        }
        getOperationLogList(parameter).then(res => {
          this.loading = false
          this.pagination.total = res.data.total
          this.data = res.data.records
        }).
        catch(err => {
          this.loading = false
        })
      },
      handleSearch() {
        this.pagination.current = 1
        this.getTableData()
      }

    }
  }
</script>

<style scoped>

</style>
